package controllers

import java.io.File

import dao._
import implicits.Implicits._
import javax.inject.Inject
import models.Tables.DataRow
import play.api.libs.json.Json
import play.api.mvc._
import tool.{FileTool, FormTool, Tool}

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

/**
 * Created by yz on 21/7/2020
 */
class DataController @Inject()(cc: ControllerComponents)(
  implicit val userDao: UserDao,
  implicit val accountDao: AccountDao,
  implicit val modeDao: ModeDao,
  implicit val dataDao: DataDao
) extends AbstractController(cc) {

  def getAllData = Action.async { implicit request =>
    dataDao.selectAll.map { rows =>
      val array = Tool.getArrayByDatas(rows.toList)
      val json = Json.toJson(array)
      Ok(json)
    }
  }




}
